// Protocol3 商户渠道配置协议数据 - 子商户模式
// 从 protocols-sub-merchant.ts 迁移而来，转换为 Protocol3 格式

import { type MerchantChannelConfig3, ProtocolType3, FieldType } from '../types/protocol3-types'

// 微信支付子商户配置
const wechatSubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_WECHAT_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_WECHAT',
  channelName: '微信支付',
  name: '微信支付子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下微信支付子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '微信支付子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'subMchId',
          fieldName: '子商户号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入子商户号',
          description: '微信支付分配的子商户号',
          helpText: '10位数字的子商户号',
          validation: {
            pattern: '^[0-9]{10}$',
            message: '子商户号应为10位数字'
          }
        },
        {
          fieldKey: 'merchantName',
          fieldName: '商户简称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户简称',
          description: '商户简称，用于支付凭证显示',
          helpText: '不超过20个字符',
          validation: {
            maxLength: 20,
            message: '商户简称不能超过20个字符'
          }
        },
        {
          fieldKey: 'contactInfo',
          fieldName: '联系方式',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系电话',
          description: '商户联系电话',
          helpText: '11位手机号码',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的手机号码'
          }
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入营业执照号',
          description: '商户营业执照号码',
          helpText: '15-18位营业执照号',
          validation: {
            pattern: '^[0-9A-Z]{15,18}$',
            message: '营业执照号格式不正确'
          }
        },
        {
          fieldKey: 'businessCategory',
          fieldName: '经营类目',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: '2001',
          options: [
            { label: '餐饮美食', value: '2001' },
            { label: '生活服务', value: '2002' },
            { label: '零售百货', value: '2003' },
            { label: '教育培训', value: '2004' },
            { label: '医疗健康', value: '2005' },
            { label: '其他', value: '9999' }
          ],
          description: '选择商户经营类目'
        }
      ],
      defaultValues: {
        subMchId: '',
        merchantName: '',
        contactInfo: '',
        businessLicense: '',
        businessCategory: '2001'
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['微信支付', '子商户'],
    category: '子商户配置',
    documentation: '微信支付子商户配置协议'
  },
  enabled: true
}

// 支付宝子商户配置
const alipaySubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_ALIPAY_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_ALIPAY',
  channelName: '支付宝',
  name: '支付宝子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下支付宝子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '支付宝子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'subMerchantId',
          fieldName: '子商户ID',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入子商户ID',
          description: '支付宝分配的子商户ID',
          helpText: '16-20位字符',
          validation: {
            pattern: '^[0-9A-Z]{16,20}$',
            message: '子商户ID格式不正确'
          }
        },
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户名称',
          description: '商户完整名称',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '商户名称不能超过50个字符'
          }
        },
        {
          fieldKey: 'merchantType',
          fieldName: '商户类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'ENTERPRISE',
          options: [
            { label: '企业商户', value: 'ENTERPRISE' },
            { label: '个体工商户', value: 'INDIVIDUAL' },
            { label: '个人商户', value: 'PERSONAL' }
          ],
          description: '选择商户类型'
        },
        {
          fieldKey: 'contactEmail',
          fieldName: '联系邮箱',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系邮箱',
          description: '商户联系邮箱',
          helpText: '有效的邮箱地址',
          validation: {
            pattern: '^[^@]+@[^@]+\\.[^@]+$',
            message: '请输入有效的邮箱地址'
          }
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入营业执照号',
          description: '商户营业执照统一社会信用代码',
          helpText: '18位统一社会信用代码',
          validation: {
            pattern: '^[0-9A-Z]{18}$',
            message: '请输入18位统一社会信用代码'
          }
        }
      ],
      defaultValues: {
        subMerchantId: '',
        merchantName: '',
        merchantType: 'ENTERPRISE',
        contactEmail: '',
        businessLicense: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['支付宝', '子商户'],
    category: '子商户配置',
    documentation: '支付宝子商户配置协议'
  },
  enabled: true
}

// 汇付天下子商户配置
const huifuSubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_HUIFU_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_HUIFU',
  channelName: '汇付天下',
  name: '汇付天下子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下汇付天下子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '汇付天下子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'subMerchantId',
          fieldName: '子商户编号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入子商户编号',
          description: '汇付天下分配的子商户编号',
          helpText: 'HF开头的编号',
          validation: {
            pattern: '^HF[0-9A-Z]{10,16}$',
            message: '子商户编号格式不正确'
          }
        },
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户名称',
          description: '商户完整名称',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '商户名称不能超过50个字符'
          }
        },
        {
          fieldKey: 'merchantType',
          fieldName: '商户类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'ENTERPRISE',
          options: [
            { label: '企业', value: 'ENTERPRISE' },
            { label: '个体户', value: 'INDIVIDUAL' },
            { label: '小微商户', value: 'MICRO' }
          ],
          description: '选择商户类型'
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入营业执照号',
          description: '营业执照统一社会信用代码',
          helpText: '15-18位营业执照号',
          validation: {
            pattern: '^[0-9A-Z]{15,18}$',
            message: '营业执照号格式不正确'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系电话',
          description: '商户联系电话',
          helpText: '11位手机号码',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的手机号码'
          }
        }
      ],
      defaultValues: {
        subMerchantId: '',
        merchantName: '',
        merchantType: 'ENTERPRISE',
        businessLicense: '',
        contactPhone: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['汇付天下', '子商户'],
    category: '子商户配置',
    documentation: '汇付天下子商户配置协议'
  },
  enabled: true
}

// 乐刷支付子商户配置
const leshuaSubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_LESHUA_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_LESHUA',
  channelName: '乐刷支付',
  name: '乐刷支付子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下乐刷支付子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '乐刷支付子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'merchantNo',
          fieldName: '商户编号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户编号',
          description: '乐刷支付分配的商户编号',
          helpText: '格式：LS开头后跟10-14位数字',
          validation: {
            pattern: '^LS[0-9]{10,14}$',
            message: '商户编号格式不正确，应为LS开头'
          }
        },
        {
          fieldKey: 'disableCreditCard',
          fieldName: '是否禁用信用卡',
          fieldType: FieldType.SWITCH,
          required: false,
          defaultValue: false,
          description: '是否禁用信用卡支付选项',
          helpText: '开启后将禁用信用卡支付功能'
        },
        {
          fieldKey: 'transactionFlag',
          fieldName: '交易标志',
          fieldType: FieldType.RADIO,
          required: false,
          defaultValue: 'D1',
          description: '选择交易标志类型',
          helpText: 'D0为实时交易，D1为T+1交易',
          options: [
            { label: 'D0交易', value: 'D0' },
            { label: 'D1交易', value: 'D1' }
          ]
        }
      ],
      defaultValues: {
        merchantNo: '',
        disableCreditCard: false,
        transactionFlag: 'D1'
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-15',
    updateTime: '2024-01-15',
    tags: ['乐刷支付', '子商户', '第三方渠道'],
    category: '子商户配置',
    documentation: '乐刷支付子商户配置协议，支持微信支付、支付宝等多种支付方式'
  },
  enabled: true
}

// 斗拱支付子商户配置
const dougongSubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_DOUGONG_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_DOUGONG',
  channelName: '斗拱支付',
  name: '斗拱支付子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下斗拱支付子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '斗拱支付子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'subMerchantNo',
          fieldName: '子商户号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入子商户号',
          description: '斗拱支付分配的子商户号',
          helpText: '格式：DG开头后跟10-14位数字',
          validation: {
            pattern: '^DG[0-9]{10,14}$',
            message: '子商户号格式不正确，应为DG开头'
          }
        },
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户名称',
          description: '商户完整名称',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '商户名称不能超过50个字符'
          }
        },
        {
          fieldKey: 'merchantLevel',
          fieldName: '商户等级',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'STANDARD',
          description: '选择商户等级',
          options: [
            { label: '标准商户', value: 'STANDARD' },
            { label: '优质商户', value: 'PREMIUM' },
            { label: 'VIP商户', value: 'VIP' }
          ]
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入营业执照号',
          description: '营业执照号或统一社会信用代码',
          helpText: '格式：15-18位字符',
          validation: {
            pattern: '^[0-9A-Z]{15,18}$',
            message: '营业执照号格式不正确'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系电话',
          description: '商户联系电话',
          helpText: '格式：11位手机号码',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的手机号码'
          }
        }
      ],
      defaultValues: {
        subMerchantNo: '',
        merchantName: '',
        merchantLevel: 'STANDARD',
        businessLicense: '',
        contactPhone: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['斗拱支付', '子商户'],
    category: '子商户配置',
    documentation: '斗拱支付子商户配置协议'
  },
  enabled: true
}

// 拉卡拉子商户配置
const lakalaSubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_LAKALA_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_LAKALA',
  channelName: '拉卡拉',
  name: '拉卡拉子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下拉卡拉子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '拉卡拉子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'subMerchantId',
          fieldName: '子商户编号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入子商户编号',
          description: '拉卡拉分配的子商户编号',
          helpText: '格式：LKL开头后跟10-15位数字',
          validation: {
            pattern: '^LKL[0-9]{10,15}$',
            message: '子商户编号格式不正确，应为LKL开头'
          }
        },
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户名称',
          description: '商户完整名称',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '商户名称不能超过50个字符'
          }
        },
        {
          fieldKey: 'terminalId',
          fieldName: '终端号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入终端号',
          description: '拉卡拉分配的终端号',
          helpText: '格式：8-12位数字',
          validation: {
            pattern: '^[0-9]{8,12}$',
            message: '终端号应为8-12位数字'
          }
        },
        {
          fieldKey: 'merchantType',
          fieldName: '商户类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'ENTERPRISE',
          description: '选择商户类型',
          options: [
            { label: '企业商户', value: 'ENTERPRISE' },
            { label: '个体工商户', value: 'INDIVIDUAL' },
            { label: '小微商户', value: 'MICRO' }
          ]
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入营业执照号',
          description: '营业执照统一社会信用代码',
          helpText: '格式：15-18位字符',
          validation: {
            pattern: '^[0-9A-Z]{15,18}$',
            message: '营业执照号格式不正确'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系电话',
          description: '商户联系电话',
          helpText: '格式：11位手机号码',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的手机号码'
          }
        }
      ],
      defaultValues: {
        subMerchantId: '',
        merchantName: '',
        terminalId: '',
        merchantType: 'ENTERPRISE',
        businessLicense: '',
        contactPhone: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['拉卡拉', '子商户'],
    category: '子商户配置',
    documentation: '拉卡拉子商户配置协议'
  },
  enabled: true
}

// 富友支付子商户配置
const fuiouSubMerchantConfig: MerchantChannelConfig3 = {
  protocolId: 'PROTOCOL3_FUIOU_SUB_MERCHANT',
  protocolType: ProtocolType3.MERCHANT_CHANNEL_CONFIG_V3,
  channelCode: 'CHANNEL_IF_FUIOU',
  channelName: '富友支付',
  name: '富友支付子商户渠道配置',
  version: '3.0.0',
  description: '服务商模式下富友支付子商户渠道配置参数',
  configType: 'SUB_MERCHANT',
  configSections: [
    {
      sectionKey: 'basic',
      sectionName: '基础配置',
      description: '富友支付子商户基础配置',
      icon: 'SettingOutlined',
      order: 1,
      collapsed: false,
      fields: [
        {
          fieldKey: 'subMerchantId',
          fieldName: '子商户编号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入子商户编号',
          description: '富友支付分配的子商户编号',
          helpText: '格式：FY开头后跟10-15位数字',
          validation: {
            pattern: '^FY[0-9]{10,15}$',
            message: '子商户编号格式不正确，应为FY开头'
          }
        },
        {
          fieldKey: 'merchantName',
          fieldName: '商户名称',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入商户名称',
          description: '商户完整名称',
          helpText: '不超过50个字符',
          validation: {
            maxLength: 50,
            message: '商户名称不能超过50个字符'
          }
        },
        {
          fieldKey: 'instCode',
          fieldName: '机构代码',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入机构代码',
          description: '富友支付分配的机构代码',
          helpText: '格式：6-12位字符',
          validation: {
            pattern: '^[0-9A-Z]{6,12}$',
            message: '机构代码格式不正确'
          }
        },
        {
          fieldKey: 'merchantType',
          fieldName: '商户类型',
          fieldType: FieldType.SELECT,
          required: true,
          defaultValue: 'ENTERPRISE',
          description: '选择商户类型',
          options: [
            { label: '企业商户', value: 'ENTERPRISE' },
            { label: '个体工商户', value: 'INDIVIDUAL' },
            { label: '小微商户', value: 'MICRO' }
          ]
        },
        {
          fieldKey: 'businessLicense',
          fieldName: '营业执照号',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入营业执照号',
          description: '营业执照统一社会信用代码',
          helpText: '格式：15-18位字符',
          validation: {
            pattern: '^[0-9A-Z]{15,18}$',
            message: '营业执照号格式不正确'
          }
        },
        {
          fieldKey: 'contactPhone',
          fieldName: '联系电话',
          fieldType: FieldType.INPUT,
          required: true,
          defaultValue: '',
          placeholder: '请输入联系电话',
          description: '商户联系电话',
          helpText: '格式：11位手机号码',
          validation: {
            pattern: '^1[3-9][0-9]{9}$',
            message: '请输入有效的手机号码'
          }
        }
      ],
      defaultValues: {
        subMerchantId: '',
        merchantName: '',
        instCode: '',
        merchantType: 'ENTERPRISE',
        businessLicense: '',
        contactPhone: ''
      }
    }
  ],
  uiConfig: {
    layout: 'vertical',
    labelWidth: 120
  },
  metadata: {
    author: 'AnyPay Team',
    createTime: '2024-01-01',
    updateTime: '2024-01-15',
    tags: ['富友支付', '子商户'],
    category: '子商户配置',
    documentation: '富友支付子商户配置协议'
  },
  enabled: true
}

// 导出子商户配置协议数据数组
export const protocol3SubMerchantConfigs: MerchantChannelConfig3[] = [
  wechatSubMerchantConfig,
  alipaySubMerchantConfig,
  huifuSubMerchantConfig,
  leshuaSubMerchantConfig,
  dougongSubMerchantConfig,
  lakalaSubMerchantConfig,
  fuiouSubMerchantConfig
]
